<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <caption>员工列表</caption>
    <tr>
        <th>id</th>
        <th>名字</th>
        <th>工资</th>
        <th>工作</th>
        <th>操作</th>
    </tr>
    <tr v-for="p in arr">
        <td>{{p.id}}</td>
        <td><a :href="'/update.html?id='+p.id">{{p.name}}</a></td>
        <td>{{p.sal}}</td>
        <td>{{p.job}}</td>
        <td><a href="javascript:void(0)" @click="del(p.id)">删除</a></td>
    </tr>
</table>
<!--引入CDN服务器的框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el: "table",
2        data: {
            arr: []
        },
        created:function () {
            axios.get("/select").then(function (response){
                v.arr= response.data;
            })
        },
        methods: {
            del:function (id) {
                if (confirm("您确定要删除吗")){
                    axios.get("/delete?id="+id).then(function () {
                        alert("删除完成")
                        location.reload();
                    })
                }
            }
        }

    })
</script>

</body>
</html>